﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 双向绑定1改进方案
{
    public partial class Form2 : Form
    {
        private Data _data;
        public Form2()
        {
            InitializeComponent();
        }

        private void button2LoadData_Click(object sender, EventArgs e)
        {
          
            LoadData();
        }
        private void LoadData()
        {
            //textBox1.Text = Data.String1;
            //textBox2.Text = Data.String2;
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            _data = Data.Ins;
            textBox1.DataBindings.Add("Text", _data, "String1", false, DataSourceUpdateMode.OnPropertyChanged);
            textBox2.DataBindings.Add("Text", _data, "String2", false, DataSourceUpdateMode.OnPropertyChanged);
            LoadData();

        }
        private void buttonSave_Click(object sender, EventArgs e)
        {
            SaveData();
        }

        private void SaveData()
        {
            //Data.String1 = textBox1.Text;
            //Data.String2 = textBox2.Text;
        }

        private void button1Edit_Click(object sender, EventArgs e)
        {

        }
    }
}
